
package com.choosefine.it.basedata.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.choosefine.it.base.BaseController;
import com.choosefine.it.basedata.service.PriceAdjustLogService;
import com.choosefine.it.common.def.CommonConstant;
import com.choosefine.it.common.def.ResultCode;
import com.choosefine.it.common.exception.BusinessException;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
 * 项目、班组中工程、分包价格的调整记录持久化
 * 
 * Author：liaozhanggen
 * Create Date：2017年2月28日
 * Version：v2.0
 */
@RestController
@RequestMapping("log/priceadjust")
public class PriceAdjustLogController extends BaseController {

	@Autowired
	private PriceAdjustLogService priceAdjustLogService;

	
	/**
	 * 查询项目、班组中工程、分包价格的调整日志 ，根据类型（1.项目、2.班组）
	 * @throws BusinessException 
	 *
	 * @Author：liaozhanggen
	 * @Create Date：2017年2月28日
	 * @param：....
	 * @return：List<PriceAdjustLogVO>
	 */
	@ApiOperation(value="查询项目、班组中工程、分包价格的调整日志 ，根据类型（1.项目、2.班组）")
	@ApiImplicitParams({
		@ApiImplicitParam(name = "objectId", value = "如果是项目工程调整价格,则objectId=项目id,type=1", required = true, dataType = "int", paramType = "path"),
		@ApiImplicitParam(name = "type", value = "如果是分包班组调整价格,则objectId=班组id,type=2", required = true, dataType = "int", paramType = "path") })
	@GetMapping("list/{objectId}/{type}")
	public String findPriceAdjustRecordByType(@PathVariable(name="objectId") int objectId,@PathVariable(name="type") int type) throws BusinessException{
		if (objectId <= 0 || type <=0 ) {
			throw new BusinessException(ResultCode.FAILED, CommonConstant.PARAMETER_ERROR);
		}
		
		Map<String,Object> param = new HashMap<>();
		param.put("objectId", objectId);
		param.put("type", type);
		
		return responseSuccess(priceAdjustLogService.findPriceAdjustRecordByType(param));
	}
}
